package com.only4play.practice.pay.reconcile.core.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.x.file.storage.core.FileInfo;
import org.dromara.x.file.storage.core.FileStorageService;
import org.dromara.x.file.storage.core.upload.UploadPretreatment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mengdy
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("test/reconcile")
public class MainTestController {

    private final FileStorageService fileStorageService;

    @RequestMapping("/file/upload")
    public String test(){
        String content = "hello world";
        byte[] bytes = content.getBytes();
        UploadPretreatment uploadPretreatment = fileStorageService.of(bytes);
        uploadPretreatment.setOriginalFilename("test.txt");
        FileInfo upload = uploadPretreatment.upload();
        return upload.getUrl();
    }

}
